﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="XepTuDong.ascx.cs" Inherits="QuanLyKTX_Phong_XepTuDong" %>
<div class="subnav admin-views-subnav">
    <div class="container-fluid">
        <ul class="nav nav-pills">
            <li><a href="Default.aspx">Phòng</a></li>
            <li class="active"><a href="#">Xếp phòng tự động</a></li>

        </ul>
    </div>
</div>

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>


        <div class="container-fluid" id="dvGrid">
            <div class="form-horizontal form-bordered form-validate" id="create">
                <div class="page-header clearfix">
                    <h2 class="page-title pull-left">TỰ ĐỘNG XẾP PHÒNG CHO SINH VIÊN
                <span id="spinner" class="loaded"><i class="fa fa-spinner fa-spin fa-sm"></i></span>
                    </h2>
                </div>

            </div>

            <div class="editor admin-editor">

                <div id="overlay-editor">

                    <div id="StatusBox" runat="server">
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            <div class="panel panel-primary">
                                <div class="panel-heading">
                                    THÔNG TIN NĂNG LỰC PHÒNG          
                                </div>
                                <div class="panel-body">
                                    <div id="chart_div"></div>
                                    <div id="thongke">
                                        Số phòng Nam: <span id="sophongnam"></span>

                                        <br />
                                        Số giường còn trống: 
                                  <span id="sogiuongnamcontrong"></span>
                                        <br />
                                        Số Sinh viên Nam chờ duyệt: <span id="SoSinhVienNamChoDuyet"></span>
                                        <hr />
                                        Số phòng Nữ:
                                  <span id="sophongnu"></span>
                                        <br />
                                        Số giường còn trống:
                                   <span id="sogiuongnucontrong"></span>
                                        <br />
                                        Số Sinh viên Nữ chờ duyệt:
                                   <span id="SoSinhVienNuChoDuyet"></span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            <div class="panel panel-primary">
                                <div class="panel-heading">
                                    BƯỚC 1: CHỌN FILE EXCEL                    
                                </div>
                                <div class="panel-body">
                                    <div class="form-horizontal clearfix">

                                        <div class="form-group">

                                            <div class="col-sm-12">
                                                <label class="help-inline">Chọn file. Chỉ hỗ trợ tập tin Excel, có phần mở rộng là *.xlsx, *.xls</label>
                                                <asp:FileUpload ID="FileUpload1" runat="server" class="multi" accept="xlsx|xls" limit="1" />
                                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Vui lòng chọn file" ForeColor="Red" ControlToValidate="FileUpload1" ValidationGroup="upload"></asp:RequiredFieldValidator>
                                                <asp:ColorLifeButtonEx ID="btnSave" runat="server" CssClass="btn btn-success pull-right btn-header" IconClass="fa fa-save" IsShowButton="false" ToolTip="Lưu" Text="Lưu" OnClick="btnSave_ServerClick" ValidationGroup="upload" />
                                            </div>
                                        </div>

                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="panel panel-primary">
                                <div class="panel-heading">
                                    BƯỚC 2: CHỌN & XẾP PHÒNG              
                                </div>
                                <div class="panel-body">
                                    <div class="form-horizontal clearfix">


                                        <div class="form-group">
                                            <label class="col-sm-2 control-label" for="IDKhuNha">Nhà</label>
                                            <div class="col-sm-10">
                                                <asp:DropDownList runat="server" ID="IDKhuNha" CssClass="form-control" placeholder="IDKhuNha" data_rule_number="true" AutoPostBack="true" OnSelectedIndexChanged="IDKhuNha_SelectedIndexChanged" AppendDataBoundItems="true">
                                                    <asp:ListItem Value="-1">-- Chọn Nhà --</asp:ListItem>
                                                </asp:DropDownList>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            

                                                <label class="col-sm-2 control-label" for="IDPhong" id="chonphong">
                                                    Chọn phòng
                                                
                                                </label>
                                                <label class="col-sm-2 control-label" id="bochonphong" style="display: none">Bỏ chọn</label>
                                            

                                            <div class="col-sm-10">
                                                <asp:CheckBoxList ID="IDPhong" runat="server" RepeatDirection="Horizontal" RepeatColumns="20" AppendDataBoundItems="true">
                                                </asp:CheckBoxList>

                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-2 control-label" for="LoaiPhong">Loại phòng</label>
                                            <div class="col-sm-10">
                                                <asp:RadioButtonList ID="LoaiPhong" runat="server" RepeatDirection="Horizontal">
                                                    <asp:ListItem Value="True" Selected="True">Nam</asp:ListItem>
                                                    <asp:ListItem Value="False">Nữ</asp:ListItem>
                                                </asp:RadioButtonList>
                                            </div>
                                        </div>
                                    </div>

                                    <asp:ColorLifeButtonEx ID="ColorLifeButtonEx1" runat="server" Text="Xếp phòng" CssClass="btn btn-danger" ToolTip="Xếp phòng tự động" IconClass="fa fa-bolt" OnClick="Button2_Click" />
                                    <asp:Label ID="lblThongBao" runat="server" Text="" ForeColor="Red"></asp:Label>
                                </div>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>


    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="IDKhuNha" EventName="SelectedIndexChanged" />
        <asp:PostBackTrigger ControlID="btnSave" />
    </Triggers>
</asp:UpdatePanel>
<!--Load the AJAX API-->



<script type="text/javascript">

    function CheckBoxListSelect(cbControl, state) {
        var chkBoxList = document.getElementById(cbControl);
        var chkBoxCount = chkBoxList.getElementsByTagName("input");
        for (var i = 0; i < chkBoxCount.length; i++) {
            chkBoxCount[i].checked = state;
        }

        return false;
    }

    function loadData() {
        $.ColorLife.jsonThongKeChiTiet(function (data) {

            var obj = $("#thongke");
            obj.find("#sophongnam").html(data.SoPhongNam);
            obj.find("#sophongnu").html(data.SoPhongNu);
            obj.find("#sogiuongnamcontrong").html(data.SoGiuongNamConTrong);
            obj.find("#sogiuongnucontrong").html(data.SoGiuongNuConTrong);
            obj.find("#SoSinhVienNamChoDuyet").html(data.SoSinhVienNamChoDuyet);
            obj.find("#SoSinhVienNuChoDuyet").html(data.SoSinhVienNuChoDuyet);

        });
    }

    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_pageLoaded(function (sender, e) {

        loadData();

        $("#chonphong").click(function () {
            CheckBoxListSelect("IDPhong", true);
            $("#chonphong").hide();
            $("#bochonphong").show();
        });
        $("#bochonphong").click(function () {
            CheckBoxListSelect("IDPhong", false);
            $("#chonphong").show();
            $("#bochonphong").hide();
        });
    });

</script>

